using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
using System.IO;

namespace Cephei
{
    /// <summary>
    /// Model is equvilent to a spreadsheet workbook and sheet combined.. and supports nested names
    /// </summary>
    public interface IModel : ICell, IDictionary<string, ICell>
    {
        /// <summary>
        /// Models can be nested within each other, and the root refers to the very top level item
        /// </summary>
        IModel Root { get; }

        /// <summary>
        /// Remove any items from the Model that have not been touched since the epoch
        /// This function can be used in Excel in conjunction with Ctrl-Alt-F9 handler
        /// </summary>
        void Clean (DateTime epoch);

        /// <summary>
        /// Call Calculate on every item in the model
        /// This is implemente for scenarios where a library implements global settings that are not visible to the Cell dependancy map
        /// </summary>
        void Calculate ();

        /// <summary>
        /// Find partially qualified Cell in the Model
        /// </summary>
        /// <param name="mnmonic">the name to find</param>
        /// <param name="from">the sub-model that upwardly deligated this query (to avoid duplicate search)</param>
        /// <returns>the Cell or null if not found</returns>
        ICell Find (Queue<string> mnmonic);

        /// <summary>
        /// Add this cell to the model, adding intermediate elements as required "clean = [/book1/sheet1/a1] * [GBPUSD]"
        /// </summary>
        /// <param name="mnmonic">the delimited name of the mnmonic</param>
        /// <param name="cell">the actual cell</param>
        void Add (Queue<string> mnmonic, ICell cell);

        /// <summary>
        /// Link the the dependancies of calculations to the equivilent references within the model
        /// </summary>
        void Link ();
    }

}
